<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>登入</title>
    <script type="text/javascript" src="js/jquery-3.3.1.js"></script>
</head>
<body>
<form id="login-form">
    <label>
        username:
        <input name="username">
    </label><br>
    <label>
        password:
        <input name="password">
    </label><br>
    <input type="button" onclick="login()" value="login">
</form>
<script>
    function login() {
        var username = $("#login-form input[name='username']").val();
        var password = $("#login-form input[name='password']").val();
        $.ajax({
            url: '/login',
            type: 'post',
            dataType: 'json',
            headers: {
                Authorization: 'Basic YXBwOmFwcHNlY3JldA=='
            },
            data: {
                username: username,
                password: password
            },
            success: function (data) {
                console.log(data);
            },
            error: function (data) {
                console.log(data)
            }
        });
    }
</script>
</body>
</html>